<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>在线用户</title>
	<#include "./comm/meta-base.ftl" />
	<#include "./comm/meta-easyui.ftl" />
	<#include "./comm/meta-comm.ftl" />
	<link href="${basePath}/static/css/privilege.css" rel="stylesheet" />
</head>
<body>
 <div id="datagrid_toolbar">
    		 <form id="search_form" class="search-form" role="form"   method="post" >
            	<div class="row">
                      <div class="form-group col-sm-4">
                        <label class="col-sm-4 fm-label">员工姓名</label>
                        <div class="col-sm-8 fm-control">
                            <input type="text" class="form-control" name="personName" />
                        </div>
                      </div>
                      
                      <div class="form-group col-sm-4">
                        <label class="col-sm-4 fm-label">登录名</label>
                        <div class="col-sm-8 fm-control">
                            <input type="text" class="form-control" name="loginName"  />
                        </div>
                      </div>
                      <div class="form-buttons col-sm-4" >
                      	<a href="javascript:submitForm()" class="btn btn-sm  btn-blue">
                            <i class="btn-label fa  fa-search "></i>查 询</a>
                        
                        <a href="javascript:resetForm('search_form')" class="btn btn-sm btn-default  margin-left-10 ">
                            <i class="btn-label fa  fa-reply "></i>重 置</a>
                    </div>
                 </div>
            </form>
            
            <div class="buttons-preview" >
            	 <a class="btn btn-danger  btn-sm" 
                	href="javascript:kickedOut()"><i class="fa fa-plus"></i>踢出客户</a>
                 <span> 当前IP : <b style="color:red">${localIp}</b></span>
                 <span> 当前用户数 : <b style="color:red">${count}</b></span>
            </div>
        </div>
    
        <table id="data_table" class="easyui-datagrid"  border="0"  pagination="true" pageSize='20'  rownumbers="true" fitColumns="true" fit="true"
	               data-options="
	                   url: '${basePath}/session/session-list-json',
	                   method: 'get',
	                   rownumbers: true,
	                   singleSelect: true,
	                   toolbar:'#datagrid_toolbar'
	               ">
	           <thead>
	           <tr>
	           		<th data-options="field:'token',width:width(0.15),formatter:formatToken">token</th>
	                <th data-options="field:'companyName',width:width(0.1)">公司</th>
	                <th data-options="field:'departmentName',width:width(0.1)">部门</th>
	                <th data-options="field:'personName',width:width(0.1)">人员姓名</th>
	                <th data-options="field:'loginName',width:width(0.1)">登录名</th>
	               
	                <th data-options="field:'loginBrowser',width:width(0.1)">浏览器</th>
	                <th data-options="field:'browserVersion',width:width(0.1)">浏览器版本</th>
	                <th data-options="field:'loginOs',width:width(0.1)">操作系统</th>
	                <th data-options="field:'loginIp',width:width(0.1)">登录IP</th>
	                <th data-options="field:'loginTime_name',width:width(0.1)">登录时间</th>
	            </tr>
	           </thead>
	       </table>


</body>
</html>
<script type="text/javascript">
function formatToken(value,row){
	var token=getCookie("UPMS_USERTOKEN");
	if (row.token==token){
		return '<b style="color:red">'+row.token+'</b>';
	}else{
		return row.token;
	}
}

function kickedOut(){
	var row = $('#data_table').datagrid('getSelected');
	if(null!=row){
		var url="${basePath}/session/kicked-out/"+row.token;
		bootbox.confirm("你确定要踢出用户："+row.personName+"?", function (result) {
        	if (result) {
            	$.post(url,{},function(data){
					$("#data_table").datagrid("reload");
				});
         	}
        });
		
	}else{
		Notify('请选择要操作的数据', 'top-right', '5000', 'danger', 'fa-bolt', true);
	}
}


function submitForm(){
	$("#search_form").form('submit', {
		url : '${basePath}/session/session-list-json',
		success : function(data) {
			var obj = jQuery.parseJSON(data);  
			$("#data_table").datagrid('loadData',obj);
		}
	});
}


$(document).ready(function(){
	
});
</script>


